<?php
class supplier_menus{
	public function index(){
		
		$supplier_id = intval($GLOBALS['request']['supplier_id']);//餐厅id	
		if($supplier_id<1)
		{
		   exit();
		}
		//餐厅的菜单分类
	   $cate_ids = $GLOBALS['db']->getAll("select DISTINCT  cate_id from ".DB_PREFIX."supplier_location_menu where supplier_location_id=".$supplier_id);
	   //餐厅的菜单列表
       $list = $GLOBALS['db']->getAll("select lm.*,mc.name as menu_cate_name from ".DB_PREFIX."supplier_location_menu as lm left join ".DB_PREFIX."supplier_location_menu_cate as mc on lm.cate_id=mc.id where lm.supplier_location_id = {$supplier_id}  ");
       
       foreach ($cate_ids as $cak=>$cav)
       {
         foreach ($list as $lk=>$lv)
         {
          
         	if($lv['cate_id']==$cav['cate_id'])
            {
                $lv['preview']=get_abs_img_root(get_spec_image($lv['preview'],100,100,1));
            	array_push($cate_ids[$cak], $lv);
            }
            
         }
         unset($cate_ids[$cak]['cate_id']);
       }
	
        $root['item']=$cate_ids;
	   output($root);
	}

}